import apiClient from "./api-client";
import { HttpApi } from "./http-api";

export interface Platform {
  id: number;
  name: string;
  slug: string;
}

export interface Game {
  id: number;
  name: string;
  slug: string;
  background_image: string;
  metacritic: number;
  parent_platforms: { platform: Platform }[];
}

class GameApi extends HttpApi {
  constructor() {
    super("/users");
  }

  getGames() {
    const controller = new AbortController();
    const request = apiClient.get("/games", {
      signal: controller.signal,
    });
    return {
      request,
      cancel: () => controller.abort(),
    };
  }
}

export default new GameApi();
